package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Cmf_Integral;
import cn.wolfcode.trip.base.mapper.Cmf_IntegralMapper;
import cn.wolfcode.trip.base.service.ICmf_IntegralService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class Cmf_IntegralServiceImpl implements ICmf_IntegralService {
    @Autowired
    private Cmf_IntegralMapper integralMapper;


    @Override
    public void saveOrUpdate(Cmf_Integral integral) {
        Cmf_Integral cmf_integral = integralMapper.selectByUserIds(integral.getUser_id());
        if (cmf_integral == null) {
            integralMapper.insert(integral);
        } else {
            cmf_integral.setIntegral(cmf_integral.getIntegral() + integral.getIntegral());
            integralMapper.updateByPrimaryKey(cmf_integral);
        }
    }
}
